<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <meta http-equiv="X-UA-Compatible" content="IE=edge" >
  <title>TinyMCE基本使用 | Yuan，blog</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="项目上需要用到文本编辑器功能，最后决定用TinyMCE插件来完成。">
<meta property="og:type" content="article">
<meta property="og:title" content="TinyMCE基本使用">
<meta property="og:url" content="http://yuanjiahui.github.io/2016/02/29/TinyMCE使用/index.html">
<meta property="og:site_name" content="Yuan，blog">
<meta property="og:description" content="项目上需要用到文本编辑器功能，最后决定用TinyMCE插件来完成。">
<meta property="og:image" content="http://7nark3.com1.z0.glb.clouddn.com/tinymcetinymce1.jpg">
<meta property="og:image" content="http://7nark3.com1.z0.glb.clouddn.com/tinymce2.jpg">
<meta property="og:updated_time" content="2016-02-29T15:20:11.301Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="TinyMCE基本使用">
<meta name="twitter:description" content="项目上需要用到文本编辑器功能，最后决定用TinyMCE插件来完成。">
<meta name="twitter:image" content="http://7nark3.com1.z0.glb.clouddn.com/tinymcetinymce1.jpg">
  
    <link rel="alternative" href="/atom.xml" title="Yuan，blog" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  <link rel="stylesheet" href="/css/style.css">
  
<!-- Google Analytics -->
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "//hm.baidu.com/hm.js?54896bdf9af069f73c90ca20d18af29b";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>

<!-- End Google Analytics -->


</head>

<body>
  <div id="container">
    <div class="left-col">
    <div class="overlay"></div>
<div class="intrude-less">
	<header id="header" class="inner">
		<a href="/" class="profilepic">
			
			<img lazy-src="/img/tous.jpg" class="js-avatar">
			
		</a>

		<hgroup>
		  <h1 class="header-author"><a href="/">Yuan Jiahui</a></h1>
		</hgroup>

		
		<p class="header-subtitle">没事搞搞前端的小原^_^</p>
		

		
			<div class="switch-btn">
				<div class="icon">
					<div class="icon-ctn">
						<div class="icon-wrap icon-house" data-idx="0">
							<div class="birdhouse"></div>
							<div class="birdhouse_holes"></div>
						</div>
						<div class="icon-wrap icon-ribbon hide" data-idx="1">
							<div class="ribbon"></div>
						</div>
						
						
						<div class="icon-wrap icon-me hide" data-idx="3">
							<div class="user"></div>
							<div class="shoulder"></div>
						</div>
						
					</div>
					
				</div>
				<div class="tips-box hide">
					<div class="tips-arrow"></div>
					<ul class="tips-inner">
						<li>菜单</li>
						<li>标签</li>
						
						
						<li>关于我</li>
						
					</ul>
				</div>
			</div>
		

		<div class="switch-area">
			<div class="switch-wrap">
				<section class="switch-part switch-part1">
					<nav class="header-menu">
						<ul>
						
							<li><a href="/">主页</a></li>
				        
							<li><a href="/archives">所有文章</a></li>
				        
						</ul>
					</nav>
					<nav class="header-nav">
						<div class="social">
							
								
								<a class="github" target="_blank" href="https://github.com/yuanjiahui" title="github">github</a>
					        
								
								<a class="weibo" target="_blank" href="http://weibo.com/275955114?is_all=1" title="weibo">weibo</a>
					        
								
								<a class="zhihu" target="_blank" href="https://www.zhihu.com/people/yuan-jia-hui-23" title="zhihu">zhihu</a>
					        
								
								<a class="mail"   href="mailto:#" title="mail">mail</a>
								
						</div>
					</nav>
				</section>
				
				
				<section class="switch-part switch-part2">
					<div class="widget tagcloud" id="js-tagcloud">
						<a href="/tags/MarkDown/" style="font-size: 10px;">MarkDown</a> <a href="/tags/TinyMCE/" style="font-size: 10px;">TinyMCE</a> <a href="/tags/top/" style="font-size: 10px;">top</a>
					</div>
				</section>
				
				
				

				
				
				<section class="switch-part switch-part3">
				
					<div id="js-aboutme">我是谁，我从哪里来，我到哪里去？我就是我，是颜色不一样的吃货…</div>
				</section>
				
			</div>
		</div>
	</header>				
</div>

    </div>
    <div class="mid-col">
      <nav id="mobile-nav">
  	<div class="overlay">
  		<div class="slider-trigger"></div>
  		<h1 class="header-author js-mobile-header hide">Yuan Jiahui</h1>
  	</div>
	<div class="intrude-less">
		<header id="header" class="inner">
			<div class="profilepic">
			
				<img lazy-src="/img/tous.jpg" class="js-avatar">
			
			</div>
			<hgroup>
			  <h1 class="header-author">Yuan Jiahui</h1>
			</hgroup>
			
			<p class="header-subtitle">没事搞搞前端的小原^_^</p>
			
			<nav class="header-menu">
				<ul>
				
					<li><a href="/">主页</a></li>
		        
					<li><a href="/archives">所有文章</a></li>
		        
		        <div class="clearfix"></div>
				</ul>
			</nav>
			<nav class="header-nav">
				<div class="social">
					
						
						<a class="github" target="_blank" href="https://github.com/yuanjiahui" title="github">github</a>
			        
						
						<a class="weibo" target="_blank" href="http://weibo.com/275955114?is_all=1" title="weibo">weibo</a>
			        
						
						<a class="zhihu" target="_blank" href="https://www.zhihu.com/people/yuan-jia-hui-23" title="zhihu">zhihu</a>
			        
						
						<a class="mail"  href="mailto:#" title="mail">mail</a>
						
				</div>
			</nav>
		</header>				
	</div>
</nav>

      <div class="body-wrap"><article id="post-TinyMCE使用" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/2016/02/29/TinyMCE使用/" class="article-date">
  	<time datetime="2016-02-29T13:58:53.000Z" itemprop="datePublished">2016-02-29</time>
</a>
    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      TinyMCE基本使用
    </h1>
  

      </header>
      
      <div class="article-info article-info-post">
        
	<div class="article-tag tagcloud">
		<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/TinyMCE/">TinyMCE</a></li></ul>
	</div>

        

        <div class="clearfix"></div>
      </div>
      
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>项目上需要用到文本编辑器功能，最后决定用TinyMCE插件来完成。<br><a id="more"></a><br>官网：<a href="https://www.tinymce.com" target="_blank" rel="external">https://www.tinymce.com</a></p>
<h3 id="1-下载文件"><a href="#1-下载文件" class="headerlink" title="1. 下载文件"></a>1. 下载文件</h3><p><img src="http://7nark3.com1.z0.glb.clouddn.com/tinymcetinymce1.jpg" alt="cmd-markdown-logo"><br>国际化文件需要单独下载 <a href="http://archive.tinymce.com/i18n/" target="_blank" rel="external">http://archive.tinymce.com/i18n/</a></p>
<h3 id="2-引入JS文件"><a href="#2-引入JS文件" class="headerlink" title="2. 引入JS文件"></a>2. 引入JS文件</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;script type=<span class="string">"text/javascript"</span> src=<span class="string">"js/tinymce/tinymce.min.js"</span>&gt;&lt;/script&gt;</span><br></pre></td></tr></table></figure>
<blockquote>
<p>引入js以后其他文件会自动引入进来不需要单独配置<br><img src="http://7nark3.com1.z0.glb.clouddn.com/tinymce2.jpg" alt="tinyMCE"></p>
</blockquote>
<h3 id="3-初始化以及参数"><a href="#3-初始化以及参数" class="headerlink" title="3. 初始化以及参数"></a>3. 初始化以及参数</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">tinymce.init(&#123;</span><br><span class="line">       selector: <span class="string">'#mytextarea'</span>, <span class="comment">//选择器</span></span><br><span class="line">       height: <span class="number">300</span>, <span class="comment">//高度</span></span><br><span class="line">       width: <span class="number">600</span>, <span class="comment">//宽度</span></span><br><span class="line">       statusbar: <span class="literal">false</span>, <span class="comment">//底部状态栏</span></span><br><span class="line">       language: <span class="string">'zh_CN'</span>, <span class="comment">//国际化</span></span><br><span class="line">   &#125;);</span><br></pre></td></tr></table></figure>
<h3 id="4-方法"><a href="#4-方法" class="headerlink" title="4. 方法"></a>4. 方法</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">tinymce.get(<span class="string">"mytextarea"</span>).getContent();</span><br></pre></td></tr></table></figure>
<table>
<thead>
<tr>
<th>方法</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>getContent</td>
<td>获取编辑器内的HTML内容</td>
</tr>
<tr>
<td>show</td>
<td>显示所有隐藏的textarea/div编辑框</td>
</tr>
<tr>
<td>hide</td>
<td>隐藏所有显示的textarea/div编辑框</td>
</tr>
<tr>
<td>isHidden</td>
<td>判断编辑器是否隐藏</td>
</tr>
</tbody>
</table>
<h3 id="5-事件"><a href="#5-事件" class="headerlink" title="5. 事件"></a>5. 事件</h3><p>空</p>

      
    </div>
    
  </div>
  
    
<nav id="article-nav">
  
  
    <a href="/2016/02/26/markdown/" id="article-nav-older" class="article-nav-link-wrap">
      <div class="article-nav-title">markdown</div>
      <strong class="article-nav-caption">></strong>
    </a>
  
</nav>

  
</article>






<div class="duoshuo">
	<!-- 多说评论框 start -->
	<div class="ds-thread" data-thread-key="TinyMCE使用" data-title="TinyMCE基本使用" data-url="http://yuanjiahui.github.io/2016/02/29/TinyMCE使用/"></div>
	<!-- 多说评论框 end -->
	<!-- 多说公共JS代码 start (一个网页只需插入一次) -->
	<script type="text/javascript">
	var duoshuoQuery = {short_name:"yuanjiahui01"};
	(function() {
		var ds = document.createElement('script');
		ds.type = 'text/javascript';ds.async = true;
		ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
		ds.charset = 'UTF-8';
		(document.getElementsByTagName('head')[0] 
		 || document.getElementsByTagName('body')[0]).appendChild(ds);
	})();
	</script>
	<!-- 多说公共JS代码 end -->
</div>




</div>
      <footer id="footer">
  <div class="outer">
    <div id="footer-info">
    	<div class="footer-left">
    		&copy; 2016 Yuan Jiahui
    	</div>
      	<div class="footer-right">
      		<a href="http://hexo.io/" target="_blank">Hexo</a>  Theme <a href="https://github.com/litten/hexo-theme-yilia" target="_blank">Yilia</a> by Litten
      	</div>
    </div>
  </div>
</footer>
    </div>
    
  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">


<script>
	var yiliaConfig = {
		fancybox: true,
		mathjax: true,
		animate: true,
		isHome: false,
		isPost: true,
		isArchive: false,
		isTag: false,
		isCategory: false,
		open_in_new: false
	}
</script>
<script src="http://7.url.cn/edu/jslib/comb/require-2.1.6,jquery-1.9.1.min.js"></script>
<script src="/js/main.js"></script>





<script type="text/x-mathjax-config">
MathJax.Hub.Config({
    tex2jax: {
        inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
        processEscapes: true,
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
    }
});

MathJax.Hub.Queue(function() {
    var all = MathJax.Hub.getAllJax(), i;
    for(i=0; i < all.length; i += 1) {
        all[i].SourceElement().parentNode.className += ' has-jax';                 
    }       
});
</script>

<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>


  </div>
</body>
</html>